﻿using System;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace MyLab
{
    public class MyLabApplication : HttpApplication
    {
        public void Application_Start()
        {
            RegisterAreas();
            RegisterGloableFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);
        }

        void RegisterAreas()
        {
            AreaRegistration.RegisterAllAreas();
        }

        void RegisterGloableFilters(GlobalFilterCollection filters)
        {
            filters.Add(new HandleErrorAttribute());
        }

        void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional }, // Parameter defaults
                new[] { "MyLab.Mvc.Controllers" }
            );
        }
    }
}
